<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>微信签到-云校通-教师</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart style="background: #fff;">
	<div class="weui_tab tab-bottom">
		<div class="weui-header bg-blue"> 
	  		<div class="weui-header-left"> <a href="<%=basePath %>/ls" class="icon icon-109 f-white">返回</a> </div>
	    	<h1 class="weui-header-title">微信签到</h1>
	    </div>
		<div class="weui_tab_bd">
	        <div class="weui_cells" style="margin-top: 0;">
	        	<div class="weui_cell card_sign_box f-15">
	        		说明：只能在校内教学区WIFI覆盖范围内签到。教师办公室、学校大门、学校广场、有为报告厅等附近都可接收到学校WIFI。
	        	</div>
	        </div>
	        
	        <div class="weui_cells afterNone afterNoneBefore mt0">
	        	<div class="p10 f-green">上班签到时间说明</div>
	        	<div class="weui_cell card_sign_box f-15">
	        		1、上午签到：<br/>
	        		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;教师6:30-8:00，职员6:30-7:50<br/><br/>
	        		2、下午签到：13:30-14:20<br/>
	        		   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;周五下午签到13:10-14:20<br/><br/>
	        		3、周日晚上班主任签到17:00-18:00
	        	</div>
	        </div>
	        
	        <c:choose>
	        	<c:when test="${isSchool }">
	        		<div class="weui_cells tm afterNone afterNoneBefore">
			        	<p id="signResult" class="pb15 hide"></p>
			        	<p id="signSubmit" class="weui_btn weui_btn_primary signed">签到</p>
			        </div>
	        	</c:when>
	        	<c:otherwise>
	        		<div class="weui_cells tm afterNone afterNoneBefore">
	        			<p class="pb15 tm f-red">请在校内教学区WIFI覆盖范围内签到</p>
	        		</div>
	        	</c:otherwise>
	        </c:choose>
	       
	        <div id="today" class="weui_cells afterNone afterNoneBefore hide">
	        	<div class="pl15 pr10 f-green">今日签到记录</div>
	        	<div id="todayList" class="card_sign_box">
	        	
	        	</div>
	        </div>
	    </div>
	</div>
<script type="text/javascript">
	$(function() {
		today();
		$("#signSubmit").click(function() {
			var obj = $(this);
			$.ajax({
		   		url: basePath + "/ls/work/cardSign/submit",
		   		type: 'POST',
		   		dataType : "json",
		   		success: function(data) {
		   			if(data.code == '000') {
		   				$("#signResult").html('<i class="weui_icon_success"></i><span class="f-green">  签到成功！</span>').show();
		   				today();
		   			}else{
		   				$("#signResult").html('<i class="f-red weui_icon_warn"></i><span class="f-red">  '+data.msg+'</span>').show();
		   			}
					obj.remove();
		   		},
		   		error: function(data) {
		   		}
			});
		})
	})
	function today() {
		$.ajax({
	   		url: basePath + "/ls/work/today",
	   		type: 'POST',
	   		dataType : "json",
	   		success: function(data) {
	   			if(data != null && data.length > 0) {
	   				$("#today").show();
	   				var html = '';
	   				for(var i in data) {
	   					var itm = data[i];
	   					html+='<div class="weui_cell">\
						          	<div class="weui_cell_hd">\
				          		<label class="weui_label">'+(itm.signType == 1 ? '上午' : '下午')+'</label>\
				          	</div>\
			         		<div class="weui_cell_bd weui_cell_primary">'+getTime(itm.signTime,'yyyy-MM-dd hh:mm')+'</div></div>';
	   				}
	   				$("#todayList").html(html);
	   			}
 	   		},
	   		error: function(data) {
	   		}
		});
	}
</script>
</body>
</html>